<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基本资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__ADMIN_LAYUIMINI__/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="__ADMIN_LAYUIMINI__/css/public.css" media="all">
    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">
            
            <div class="layui-form-item">
                <label class="layui-form-label required">角色</label>
                <div class="layui-input-block" id="xm-select-role">
                    <!-- <select name="role_id" class="layui-form-select">
                        {volist name="roleList" id="vo"}
                            <option value="{$vo.id}">{$vo.rolename}</option>
                        {/volist}
                    </select> -->
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label required">管理账号</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required" lay-reqtext="管理账号不能为空" placeholder="请输入管理账号" value="" class="layui-input">
                    <tip>填写自己管理账号的名称，提交后不可更改。</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码"  value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">真实姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="fullname" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入真实姓名"  value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">手机</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机"  value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="email" name="email"  placeholder="请输入邮箱"  value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注信息</label>
                <div class="layui-input-block">
                    <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息"></textarea>
                </div>
            </div>

            <div>{:token_field()}</div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN_LAYUIMINI__/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="__ADMIN_LAYUIMINI__/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__ADMIN_LAYUIMINI__/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form','miniTab', 'xmSelect'], function () {
        var form = layui.form,
            layer = layui.layer,
            xmSelect = layui.xmSelect,
            miniTab = layui.miniTab;
        
        var json = '{$roleList|raw}';
        var role = xmSelect.render({
        	el: '#xm-select-role', 
            name: 'role_id',
            prop: {
                name: 'rolename',
                value: 'id',
            },
        	data: JSON.parse(json)
        })

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            data = data.field;
            url = "{:url('admin/add')}";
            var indexLoad = layer.load(1, {shade: [0.1,'#fff']});
            $.ajax({
                url,
                data,
                type:"POST",
                success(res){
                    layer.close(indexLoad);
                    layer.msg(res.message);
                    if (res.status == 1) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        window.parent.location.reload();
                        parent.layer.close(index); //再执行关闭
                    }
                }
            })
            
            return false;
        });

    });
</script>
</body>
</html>